var webpack = require("webpack");
var path = require('path');
var HtmlwebpackPlugin = require('html-webpack-plugin');

//定义了一些文件夹的路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'src');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');

module.exports = {
	entry: {
		bundle: [path.resolve(APP_PATH, "app.js"), "networkConfig", "frameScript","jsBridge"],
		vue: ["vue", "vuex", "vue-router", "vue-img-lazyload", "vue-touch", "vue-resource"],
		
	},
	output: {
		path: BUILD_PATH,
		filename: '[name]_[hash].js',
		pathinfo: false
	},
	devServer: {
		disableHostCheck: true,
		historyApiFallback: true,
		hot: false,
		inline: true,
		grogress: true,
		contentBase: BUILD_PATH
	},
	module: {
		loaders: [{
			test: /\.vue$/,
			loader: 'vue'
		}, {
			test: /\.js$/,
			exclude: /node_modules/,
			loader: 'babel-loader?presets[]=es2015',
			
//			'babel?compact=false'
		}, {
			test: /\.(jpg|png|svg)$/,
			loader: 'url?limit=8192'
		}, {
			test: /\.css$/,
			loader: 'style!css'
		}, {
			test: /\.(scss|sass)$/,
			loader: 'style!css!sass?sourceMap'
		}, {
			test: /\.less$/,
			loader: 'style!css!less?sourceMap'
		}, {
			test: /\.json$/,
			loader: 'json'
		}, {
			test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
			loader: "url-loader?limit=1&minetype=application/font-woff&name=[path][name].[ext]"
		}, {
			test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
			loader: "file-loader?name=[path][name].[ext]"
		}]
	},
	resolve: {
		//自动扩展文件后缀名，意味着我们require模块可以省略不写后缀名
		extensions: ['', '.js', '.json', '.css', '.less', '.vue', ".scss", ".sass"],
		//模块别名定义，方便后续直接引用别名，无须多写长长的地址
		alias: {
			"frameScript": ROOT_PATH + "/libs/js/frameScript.js",
			"jsBridge": ROOT_PATH + "/libs/js/jsBridge.js",
			"vue-img-lazyload": ROOT_PATH + "/plugins/vueDirective/vue.lazyimg.js",
			"vue-priceInput": ROOT_PATH + "/plugins/vueDirective/vue.priceInput.js",
			"vue-dateFilter": ROOT_PATH + "/plugins/vueFilter/vue.dateFilter.js",
			"networkConfig": ROOT_PATH + "/src/networkConfig.js",
			"HQ_Actions": ROOT_PATH + "/libs/js/vuex/actions.js",
			"HQ_Getters": ROOT_PATH + "/libs/js/vuex/getters.js",			

		}
	},
	plugins: [
		new HtmlwebpackPlugin({		
			template: path.resolve(APP_PATH, 'index.html'),
			filename: 'index.html',
			//chunks这个参数告诉插件要引用entry里面的哪几个入口
			chunks: ['bundle', 'vue'],
			//要把script插入到标签里
			inject: 'body',
			title: '查询系统',
		}),
		new webpack.ProvidePlugin({
			"Vue": "vue",
			"Vuex": "vuex",
			"VueTouch": "vue-touch",
			"frameScript": "frameScript",
			"HQ": "jsBridge"

		}),
		
	],
	devtool: 'eval-source-map',
	watch: true
}